package com.ruoyi.web.controller.wb;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.wb.domain.WbEngineerEnter;
import com.ruoyi.wb.service.IWbEngineerEnterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 工程师入驻
Controller
 * 
 * @author ruoyi
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/wb/engineer")
public class WbEngineerEnterController extends BaseController
{
    @Autowired
    private IWbEngineerEnterService wbEngineerEnterService;

    /**
     * 查询工程师入驻列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WbEngineerEnter wbEngineerEnter)
    {
        startPage();
        List<WbEngineerEnter> list = wbEngineerEnterService.selectWbEngineerEnterList(wbEngineerEnter);
        return getDataTable(list);
    }

    /**
     * 导出工程师入驻列表
     */
    @Log(title = "工程师入驻", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WbEngineerEnter wbEngineerEnter)
    {
        List<WbEngineerEnter> list = wbEngineerEnterService.selectWbEngineerEnterList(wbEngineerEnter);
        ExcelUtil<WbEngineerEnter> util = new ExcelUtil<WbEngineerEnter>(WbEngineerEnter.class);
        util.exportExcel(response, list, "工程师入驻数据");
    }

    /**
     * 获取工程师入驻详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wbEngineerEnterService.selectWbEngineerEnterById(id));
    }

    /**
     * 新增工程师入驻
     */
    @Log(title = "工程师入驻", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WbEngineerEnter wbEngineerEnter)
    {
        return toAjax(wbEngineerEnterService.insertWbEngineerEnter(wbEngineerEnter));
    }

    /**
     * 修改工程师入驻
     */
    @Log(title = "工程师入驻", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WbEngineerEnter wbEngineerEnter)
    {
        return toAjax(wbEngineerEnterService.updateWbEngineerEnter(wbEngineerEnter));
    }

    /**
     * 删除工程师入驻
     */
    @Log(title = "工程师入驻", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wbEngineerEnterService.deleteWbEngineerEnterByIds(ids));
    }

    /**
     * 工程师入驻
     */
    @GetMapping(value = "/byUser")
    public AjaxResult byUser()
    {
        return success(wbEngineerEnterService.byUser());
    }
}
